﻿/*Copyright (c) 2006-2009 Apple Inc.  All Rights Reserved.*/
(function () {
    var G = window, D = Object.prototype, F = Function.prototype, B, I, J, E = document.getElementsByTagName("head")[0], C, A, H;
    if (typeofloadFirebugConsole === "function") {
        loadFirebugConsole()
    } G.NSLog = function (K) {
        if (typeofconsole !== "undefined") {
            console.log(K)
        } else {
        }
    };
    Gianduia = {
};
G.NSEval = G["eval"];
Gianduia.isBootStrapped = false;
(function () {
    var K = navigator.userAgent, L = navigator.appVersion;
    navigator.isKHTML = ((L.indexOf("Konqueror") >= 0) || (L.indexOf("Safari") >= 0));
    navigator.isWebKit = (L.indexOf("AppleWebKit") >= 0);
    navigator.isWebKit2 = (navigator.isWebKit && (typeofElement === "undefined"));
    navigator.isWebKitMobile = navigator.isWebKit && (L.indexOf("Mobile") >= 0);
    navigator.isMozilla = ((K.indexOf("Gecko") >= 0) && (!navigator.isKHTML));
    navigator.isIE = (K.match(/msie/i) && (K.indexOf("Opera") == -1))
})();
G.NSLink = function (K) {
    if (!Gianduia || !Gianduia.isBootStrapped) {
        window.NSLink._links.push(K)
    } else {
        _Link(K)
    }
};
G.NSLink._links = [];
G.NSPackage = function (K, L) {
    if (this.constructor !== NSPackage) {
        var M = NSPackage.packageNamed(K), R, N, U = null, S = null, V = "", T = null, Q, O = "", P;
        if (M === null) {
            R = K.split(".");
            N = R.length;
            for (Q = 0; (O = R[Q]); Q++) {
                if (Q > 0) {
                    V = V + "." + O;
                    U = S;
                    S = NSPackage.packageNamed(V);
                    if (T && T.length > 0 && !(T.lastIndexOf("/") === (T.length - 1))) {
                        T += "/"
                    } T += O;
                    if (S === null) {
                        S = NSPackage.__createPackage(V, O, T, U)
                    }
                } else {
                    V = O;
                    T = L;
                    S = NSPackage.packageNamed(V);
                    if (S) {
                        T = S.url()
                    } else {
                        if (N > 1) {
                            for (P = 1; P < N; P++) {
                                T += "/.."
                            }
                        } S = NSPackage.__createPackage(V, O, T, U)
                    }
                }
            } if (R.length === 1) {
                window[K] = S
            } M = S
        } return M
    } else {
        this._name = K;
        this._url = L;
        return this
    }
};
NSPackage.__createPackage = function (O, L, N, M) {
    var K = new NSPackage(O, N);
    NSPackage.packages[O] = K;
    if (!!!M) {
        M = window
    } M[L] = K;
    return K
};
NSPackage.registerClass = function (K) {
    var L = NSPackage(K.packageName());
    L[K.className()] = K;
    K.setPackage(L)
};
NSPackage.rootPackageName = "Gianduia";
NSPackage.loadRootPackage = function (L, K) {
    NSPackage(L, K);
    NSPackage("Gianduia.Foundation");
    if (Gianduia.Foundation.NSNotificationCenter === undefined) {
        Gianduia.Foundation.NSNotificationCenter = {
    };
    Gianduia.Foundation.NSNotificationCenter.defaultCenter = {
};
Gianduia.FoundationNSNotificationCenteraddObserverArgumentsArray = [];
Gianduia.Foundation.NSNotificationCenter.defaultCenter.addObserver = function () {
    Gianduia.FoundationNSNotificationCenteraddObserverArgumentsArray[Gianduia.FoundationNSNotificationCenteraddObserverArgumentsArray.length] = arguments
}
} NSPackage("Gianduia.AppKit")
};
NSPackage.loadNocNamed_owner_ = function (L, K) {
};
NSPackage.packages = {
};
NSPackage.packageNamed = function (K) {
    return NSPackage.packages[K] || null
};
NSPackage.prototype._name = null;
NSPackage.prototype.name = function () {
    return this._name
};
NSPackage.prototype._url = null;
NSPackage.prototype.url = function () {
    return this._url
};
NSPackage.prototype.valueForKey = function (K) {
    return this[K]
};
F.alloc = function () {
    return (new this)
};
F.setClassName = F._setName = function (K) {
    this._name = K;
    this.prototype.__className = K
};
F.__name = function () {
    if (!this._name) {
        var K = this.toString();
        K = K.substring(K.indexOf(" ") + 1, K.indexOf("("));
        this.displayName = this._name = K;
        if (!this._name) {
            NSLog("Function.prototype.__name : Function name couldn't be found")
        } else {
            this.displayName = this._name
        }
    } return this._name
};
F.className = function () {
    return this._name ? this._name : this.__name()
};
F.superclass = function () {
    return this.parent
};
F.setQualifiedClassName = function (M, L) {
    this._qualifiedClassName = M;
    var K = M.split(".");
    this.setClassName(K.pop());
    this.setPackageName(K.join("."));
    if (!L) {
        L = this.className()
    } if (window[L] === undefined) {
        window[L] = this
    } else {
        NSLog('Function.prototype.setQualifiedClassName("' + M + ',"' + L + '"): Global symbol ' + L + " already exists.")
    }
};
F._qualifiedClassName = null;
F._initializedQualifiedClassName = function () {
    return this._qualifiedClassName
};
F.qualifiedClassName = function () {
    if (this._qualifiedClassName === null) {
        this._qualifiedClassName = ((this.packageName()) ? (this.packageName() + ".") : "") + this.className();
        this.qualifiedClassName = this._initializedQualifiedClassName
    } return this._qualifiedClassName
};
F._loaded = false;
F.isLoaded = function () {
    return this._loaded
};
F.setPackage = function (K) {
    this.__package = K
};
F._package = function () {
    return this.__package
};
F.setPackageName = function (K) {
    this._packageName = K;
    NSPackage.registerClass(this)
};
F.packageName = function () {
    return this._packageName
};
(function () {
    var L = document.getElementsByTagName("script"), P = new RegExp("(__package__|" + NSPackage.rootPackageName + ").js([?.]|$)", "i"), N = 0, K = null, O, M;
    while ((K = L[N++])) {
        O = K.getAttribute("src");
        if (!O || ((typeofO === "string") && (O.length === 0))) {
            continue
        } M = O.match(P);
        if (M) {
            NSPackage.loadRootPackage(NSPackage.rootPackageName, O.substring(0, M.index) + "");
            Gianduia.isBootStrapped = false;
            break
        }
    } K = null;
    L = null
})();
Gianduia._createScriptWithSource = function (L) {
    var K = document.createElement("script");
    K.setAttribute("type", "text/javascript");
    K.id = K.src = L;
    return K
};
Gianduia._createWebKitLoadScriptForScript = function (L, K, O) {
    var P = L.id, N = document.createElement("script"), M = 'var delayedFunction = function() {var evt = document.createEvent("HTMLEvents");\nevt.initEvent("load",true, true);\nNSLog("element for ' + P + ' = "+document.getElementById("' + P + '"));\ndocument.getElementById("' + P + '").dispatchEvent(evt);}\nsetTimeout(delayedFunction,0);';
    N.setAttribute("type", "text/javascript");
    N.appendChild(document.createTextNode(M));
    if (O) {
        if (K) {
            K.insertBefore(N, O)
        }
    } else {
        if (K) {
            K.appendChild(N)
        }
    } return N
};
Gianduia.appendScriptWithSourceWithParent = function (M, K, N) {
    var L = this._createScriptWithSource(M);
    if (!L.hasAttribute) {
        NSLog("Graft didn't take!!!! src = " + M)
    } if (typeofN === "function") {
        L.addEventListener("load", N, false)
    } if (K) {
        K.appendChild(L)
    } if (navigator.isWebKit2) {
        this._createWebKitLoadScriptForScript(L, K)
    } return L
};
Gianduia.appendScriptsWithSourceInParent = function (M, O, K) {
    var P = document.createDocumentFragment(), L = 0, N = null;
    while ((N = M[L++])) {
        this.appendScriptWithSourceWithParent(N, P, O)
    } if (K) {
        K.appendChild(P)
    } P = null
};
Gianduia.windowLoaded = false;
Gianduia.bootStrapOnLoad = true;
Gianduia._bootStrap = function () {
    if (Gianduia.bootStrapOnLoad) {
        Gianduia.windowLoaded = true
    } (function () {
        if (navigator.isIE) {
            var K = document.createElement("script");
            K.setAttribute("type", "text/javascript");
            K.setAttribute("src", (Gianduia.url() + "/IE.js"));
            K.loaded = false;
            K.defer = "defer";
            K.onreadystatechange = function () {
                if (!this.loaded && ((this.readyState == "complete") || (this.readyState == "loaded"))) {
                    if (this.readyState == "complete") {
                        Gianduia.isIELoadingStringFromCache = true
                    } this.onreadystatechange = null;
                    Gianduia.completeInitialization();
                    document.body.insertBefore(NSLogElement, document.body.firstChild);
                    K = null
                }
            };
            E.appendChild(K)
        } else {
            Gianduia.completeInitialization()
        }
    })()
};
(Gianduia.bootStrapOnLoad) ? (G.onload = Gianduia._bootStrap) : Gianduia._bootStrap();
Gianduia.completeInitialization = function () {
    if (!String.prototype.stringByAppendingPathComponent) {
        String.prototype.stringByAppendingPathComponent = function (L) {
            return (this.lastIndexOf("/") !== (this.length - 1)) ? (this + "/" + L) : (this + L)
        }
    } Gianduia.scriptId = 0;
    Gianduia.onloadCallbackWithCountNextBatchFunction = function (M, N) {
        var L = function (P) {
            var O = arguments.callee;
            if (navigator.isIE) {
                P.srcElement.detachEvent("onload", O)
            } else {
                P.target.removeEventListener("load", O, false)
            } if (M === ++O.batchLoadedCount) {
                N()
            }
        };
        L.batchLoadedCount = 0;
        return L
    };
    function K(L) {
        var M = function () {
            var N = null, P = ["Gianduia.Foundation.NSDOMNode", "Gianduia.Foundation.NSString", "Gianduia.Foundation.NSArray", "Gianduia.Foundation.NSDictionary", "Gianduia.Foundation.NSNotificationCenter", "Gianduia.Foundation.NSHTTPRequest", "Gianduia.Foundation.NSException", "Gianduia.Foundation.NSKeyValueCoding", "Gianduia.Foundation.NSImport", "Gianduia.Foundation.NSObject"], R = 0, T, O, Q, S;
            while ((T = P[R++])) {
                N = window.NSImport.importNamed(T);
                N.setIsLoaded(true)
            } Gianduia.Foundation.NSNotification._loaded = true;
            Gianduia.Foundation.NSNotificationCenter._loaded = true;
            Gianduia.Foundation.NSObject._loaded = true;
            if (navigator.isIE) {
                if (L) {
                    L.srcElement.detachEvent("onload", K)
                } Gianduia.Foundation.NSNotificationCenter.defaultCenter.addObserver(Gianduia, NSRemoveInternetExplorerGianduiaPropertiesToElements, "unload", window)
            } else {
                if (L) {
                    L.target.removeEventListener("load", K, false)
                }
            } O = window.NSLink._links;
            R = 0;
            while ((S = O[R++])) {
                _Link(S)
            } delete window.NSLink._links;
            Gianduia.isBootStrapped = true;
            G = null;
            D = null;
            F = null;
            E = null;
            S = null
        };
        if (navigator.isMozilla) {
            setTimeout(M, 0)
        } else {
            M()
        }
    } Gianduia.loadSecondBatch = function () {
        if (navigator.isIE) {
            Gianduia.addIEBehavior(document, Gianduia.url() + "IE.htc")
        } var R = NSPackage("Gianduia.Foundation").url(), O = [typeofGianduia.Foundation.NSException, typeofwindow.NSFile, typeofdocument.valueForUndefinedKey], U = ["NSException.js", "NSImport.js", "NSKeyValueCoding.js"], L = [], P = 0, T, V = document.createElement("link"), S = document.getElementsByTagName("head")[0], Q = Gianduia.FoundationNSNotificationCenteraddObserverArgumentsArray, N = Gianduia.Foundation.NSNotificationCenter.defaultCenter, M = Gianduia.Foundation.NSNotificationCenter.prototype.addObserver;
        P = 0;
        while ((iArguments = Q[P++])) {
            M.apply(N, iArguments)
        } V.setAttribute("href", Gianduia.url() + "Gianduia.css");
        V.rel = "Stylesheet";
        V.media = "Screen";
        V.type = "text/css";
        S.insertBefore(V, S.firstChild);
        for (P = 0; (T = O[P]); P++) {
            if (T !== "function") {
                L[L.length] = R.stringByAppendingPathComponent(U[P])
            }
        } (L.length > 0) ? Gianduia.appendScriptsWithSourceInParent(L, Gianduia.onloadCallbackWithCountNextBatchFunction(L.length, K), S) : K()
    };
    (function () {
        var O = NSPackage("Gianduia.Foundation").url(), N = [typeofString.prototype.hasPrefix, typeofArray.prototype.addObject, typeofGianduia.Foundation.NSDictionary, typeofE.clonedInnerDocumentFragment, typeofGianduia.Foundation.NSNotificationCenter, typeofGianduia.Foundation.NSHTTPRequest, typeofGianduia.Foundation.NSObject], P = ["NSString.js", "NSArray.js", "NSDictionary.js", "NSDOMNode.js", "NSNotificationCenter.js", "NSHTTPRequest.js", "NSObject.js"], L = [], M, Q;
        for (M = 0; (Q = N[M]); M++) {
            if (Q !== "function") {
                L[L.length] = O.stringByAppendingPathComponent(P[M])
            }
        } (L.length > 0) ? Gianduia.appendScriptsWithSourceInParent(L, Gianduia.onloadCallbackWithCountNextBatchFunction(L.length, Gianduia.loadSecondBatch), E) : Gianduia.loadSecondBatch();
        return
    })()
};
Math.PI_2 = (Math.PI / 2);
Math.PI_2_2 = (Math.PI_2 / 2);
Math.integerDivide = function (K, L) {
    return (K - (K % L)) / L
};
Math.fabs = function (K) {
    return (K < 0) ? -K : K
};
G.NSNotFound = 2147483647;
G.NSComparisonResult = {
    NSOrderedAscending: -1, NSOrderedSame: 0, NSOrderedDescending: 1
};
Number.NSUIntegerMax = Number.MAX_VALUE;
Date.prototype.isEqual = function (K) {
    return (K != null && this.getMilliseconds() === K.getMilliseconds())
};
G.NSRange = function (L, K) {
    this.location = L;
    this.length = K;
    return this
};
G.NSMakeRange = function (L, K) {
    return new NSRange(L, K)
};
G.NSMaxRange = function (K) {
    return (K.location + K.length)
};
G.NSLocationInRange = function (K, L) {
    return (K - L.location < L.length)
};
G.NSEqualRanges = function (L, K) {
    return (L.location === K.location && L.length === K.length)
};
G.NSUnionRange = function (L, K) {
    var N = L.location + L.length, M = K.location + K.length, O = L.location < K.location ? L.location : K.location;
    return NSMakeRange(O, ((N < M) ? M : N) - O)
};
G.NSIntersectionRange = function (L, K) {
    var N = L.location + L.length, M = K.location + K.length, O = (N < M) ? N : M;
    if (K.location <= L.location && L.location < M) {
        return NSMakeRange(L.location, O - L.location)
    } else {
        if (L.location <= K.location && K.location < N) {
            return NSMakeRange(K.location, O - K.location)
        }
    } return NSMakeRange(0, 0)
};
G.NSIntersectsRange = function (L, K) {
    return (L.location < K.location + K.length && K.location < L.location + L.length)
};
G.NSOffset = function (P, O, M, L, N, K) {
    this.left = P;
    this.top = O;
    this.right = M;
    this.bottom = L;
    this.width = N;
    this.height = K;
    return this
};
G.NSMakeOffset = function (P, O, M, L, N, K) {
    return new NSOffset(P, O, M, L, N, K)
};
G.NSPoint = function (K, L) {
    this.x = K;
    this.y = L;
    return this
};
G.NSPoint.prototype.takeValuesFromPoint = function (K) {
    this.x = K.x;
    this.y = K.y
};
G.NSZeroPoint = {
    x: 0, y: 0
};
G.NSMakePoint = function (K, L) {
    return new NSPoint(K, L)
};
G.NSEqualPoints = function (L, K) {
    return ((L.x === K.x) && (L.y === K.y))
};
G.NSSize = function (L, K) {
    this.width = L;
    this.height = K;
    return this
};
G.NSSize.prototype.takeValuesFromSize = function (K) {
    this.width = K.width;
    this.height = K.height
};
G.NSZeroSize = {
    width: 0, height: 0
};
G.NSMakeSize = function (L, K) {
    return new NSSize(L, K)
};
G.NSRect = function (K, L) {
    this.origin = (!K) ? NSMakePoint(0, 0) : K;
    this.size = (!L) ? NSMakeSize(0, 0) : L;
    return this
};
G.NSRect.prototype.takeValuesFromRect = function (K) {
    if (!this.origin) {
        this.origin = NSMakePoint(0, 0)
    } this.origin.takeValuesFromPoint(K.origin);
    if (!this.size) {
        this.size = NSMakeSize(0, 0)
    } this.size.takeValuesFromSize(K.size)
};
G.NSZeroRect = {
    origin: NSZeroPoint, size: NSZeroSize
};
G.NSMakeRect = function (K, N, L, M) {
    return new NSRect(NSMakePoint(K, N), NSMakeSize(L, M))
};
G.NSMaxX = function (K) {
    return (K.origin.x + K.size.width)
};
G.NSMaxY = function (K) {
    return (K.origin.y + K.size.height)
};
G.NSMidX = function (K) {
    return (K.origin.x + K.size.width / 2)
};
G.NSMidY = function (K) {
    return (K.origin.y + K.size.height / 2)
};
G.NSMinX = function (K) {
    return K.origin.x
};
G.NSMinY = function (K) {
    return K.origin.y
};
G.NSWidth = function (K) {
    return K.size.width
};
G.NSHeight = function (K) {
    return K.size.height
};
G.NSResetRect = function (K) {
    K.origin.x = K.origin.y = K.size.width = K.size.height = 0
};
D.isKindOfClass = function (K) {
    return (K) ? thisinstanceofK : false
};
D.self = function () {
    return this
};
G.Implements = D.Implements = function (S) {
    var X = "static ", P = (typeofthis.prototype !== "undefined") ? this.prototype : this, R, U, O, Q, L = "+", V = false, T, N = null, W, M = this.className ? "[" + this.className() + " " : this.toString(), K;
    if (S) {
        for (T in S) {
            if (S.hasOwnProperty(T)) {
                R = S[T];
                U = false;
                V = false;
                O = null;
                Q = P;
                K = (typeofR === "function");
                if (T.indexOf(X) === 0) {
                    U = true;
                    T = (O = T.split(X))[1];
                    Q = this;
                    if (K) {
                        R.displayName = "s " + M + T + "]"
                    }
                } else {
                    if (T.indexOf(L) === 0) {
                        V = true;
                        if ((T = (O = T.split(L))[1]) === "load") {
                            N = R
                        } if (R && R.isProperty) {
                            if (!R.propertyDescription) {
                                R.propertyDescription = {
                            }
                        } R.propertyDescription.isClassMethod = true;
                        R.createPropertyNamed.call(P, (T), R.propertyDescription);
                        continue
                    } else {
                        P["__class__" + T] = R;
                        R.displayName = "+ " + M + T + "]"
                    } Q = this;
                    if (typeofFunction.prototype[T] !== "function") {
                        (Function.prototype[T] = (new Function("return function() {return typeof this.prototype.__class__" + T + " === 'function' ? this.prototype.__class__" + T + ".apply(this,arguments) : undefined;}"))()).isClassMethod = true
                    } else {
                        if (Function.prototype[T].isClassMethod !== true) {
                            Gianduia.Foundation.NSException.raiseExceptionWithNameReasonUserInfo(NSInternalInconsistencyException, "Conflict: Function method " + T + " already exists but isn't declared as a class method where class " + this.qualifiedClassName + " declare it as such")
                        }
                    } R = (new Function("return function() {return " + this.qualifiedClassName() + ".prototype.__class__" + T + ".apply(this,arguments);}"))()
                }
            } if (R && R.isProperty) {
                R.createPropertyNamed.call(Q, T, R.propertyDescription)
            } else {
                Q[T] = R;
                if (K) {
                    R.displayName = "- " + M + T + "]"
                }
            }
        }
    }
} if (N) {
    N.call(this)
} else {
    if (this.shouldExtends && P.__class__load) {
        this.load()
    }
} return N
};
Function.emptyFunction = function () {
};
F.argumentArray = function () {
    return Array.prototype.slice.apply(arguments)
};
F.propertyNames = function () {
    return this._propertyNames
};
F.addPropertyNamed = function (K) {
    if (!this._propertyNames) {
        this._propertyNames = []
    } if (!this._propertyNames.hasOwnProperty(K)) {
        this._propertyNames[K] = this._propertyNames.length;
        this._propertyNames[this._propertyNames.length] = K
    }
};
G.NSProperty = function (K) {
    return {
        isProperty: true, propertyDescription: K, createPropertyNamed: arguments.callee.createPropertyNamed
    }
};
G.NSProperty.createPropertyNamed = function (Q, U) {
    var K = null, N = null, T = Q, M = Q, S = null, O, L, V = false, W, P = Q, R;
    if (U) {
        K = U.setterImplementation;
        N = U.getterImplementation;
        M = T = (typeofU.getter === "string") ? U.getter : Q;
        L = O = (typeofU.setter === "string") ? U.setter : this.setterSelectorForKey(Q);
        if ((V = !!U.isClassMethod)) {
            R = Function.prototype;
            P = "__class__" + Q;
            M = "__class__" + M;
            L = "__class__" + L;
            if (typeofR[T] !== "function") {
                (R[T] = function () {
                    return this.prototype["__class__" + T].apply(this, arguments)
                }).isClassMethod = true
            } else {
                if (R[T].isClassMethod !== true) {
                    Gianduia.Foundation.NSException.raiseExceptionWithNameReasonUserInfo(NSInternalInconsistencyException, "Conflict: Function method " + T + " already exists but isn't declared as a class method where class " + this.constructor.qualifiedClassName + " declare it as such")
                }
            }
        }
    } else {
        L = O = this.setterSelectorForKey(Q)
    } P = "_" + P;
    this[P] = (U && U.hasOwnProperty("defaultValue")) ? U.defaultValue : null;
    (S = this[M] = (typeofN === "function") ? N : (V ? (function () {
        return this.prototype[P]
    }) : (function () {
        return this[P]
    }))).displayName = (W = ((V ? "+ [" : "- [") + this.constructor.className() + " ")) + T + "]";
    if (!((!U || typeofU.readonly !== "boolean") ? false : U.readonly) && ((!U || typeofU.readwrite !== "boolean") ? true : U.readwrite)) {
        (S.__setter = this[L] = (typeofK === "function") ? K : (V ? (function (X) {
            this.prototype[P] = X
        }) : (function (X) {
            this[P] = X
        }))).displayName = W + O + "]"
    } if (V) {
        if (typeofR[O] !== "function") {
            (R[O] = (new Function("return function() {return this.prototype." + L + ".apply(this,arguments);}"))()).isClassMethod = true
        } else {
            if (R[O].isClassMethod !== true) {
                Gianduia.Foundation.NSException.raiseExceptionWithNameReasonUserInfo(NSInternalInconsistencyException, "Conflict: Function method " + key + " already exists but isn't declared as a class method where class " + this.constructor.qualifiedClassName + " declare it as such")
            }
        }
    }
};
D.addNSPropertyNamed = function (L, K) {
    NSProperty.call(window, L).createPropertyNamed.call(this, K, L)
};
H = function () {
};
H.setQualifiedClassName("Gianduia.Foundation.NSDelegateProxy");
H.Implements({
    "+delegateProxyForOwnerPropertyNamePropertyDescription": function (K, M, P) {
        var N = new window.NSDelegateProxy, Q = P.delegateSelectorNames, L = P.delegateNotificationSelectorNames, O = P.ownerDelegateSelectorPrefixSelector;
        if (!Q) {
            Gianduia.Foundation.NSException.raiseExceptionWithNameReasonUserInfo(NSException.NSGenericException, "NSDelegateProxy needs delegateSelectorNames specified", null)
        } N._ownerDelegateSelectorPrefixSelector = O;
        N._propertyName = M;
        N._owner = K;
        N._delegateSelectorNames = Q;
        N._delegateNotificationSelectorNames = L;
        N._ownerDelegateSelectorPrefixSelectorMethod = (N._owner && typeofN._owner[N._ownerDelegateSelectorPrefixSelector] === "function") ? N._owner[N._ownerDelegateSelectorPrefixSelector] : null;
        return N
    }, delegateSelectorNameArray: function () {
        if (!this._delegateSelectorNameArray) {
            this._delegateSelectorNameArray = ((typeofthis._delegateSelectorNames === "string") ? this._owner[this._delegateSelectorNames]() : ((this._delegateSelectorNames.constructor === Array) ? this._delegateSelectorNames : null))
        } return this._delegateSelectorNameArray
    }, delegateNotificationSelectorNameDictionary: function () {
        if (!this._delegateNotificationSelectorNameDictionary && this._delegateNotificationSelectorNames) {
            this._delegateNotificationSelectorNameDictionary = ((typeofthis._delegateNotificationSelectorNames === "string") ? this._owner[this._delegateNotificationSelectorNames]() : ((this._delegateNotificationSelectorNames.isKindOfClass(Gianduia.Foundation.NSDictionary)) ? this._delegateNotificationSelectorNames : null))
        } return this._delegateNotificationSelectorNameDictionary
    }, respondsToSelector: function (K) {
        return this._delegateBitField.valueForKey(K)
    }, delegateBitField: function () {
        if (!this._delegateBitField) {
            this._delegateBitField = new A(this._owner[this._propertyName + "BitFieldDefinition"]())
        } return this._delegateBitField
    }, delegate: function (K) {
        return this._delegate
    }, setDelegate: function (Q) {
        if (Q === this._delegate) {
            return
        } var K = this.delegateBitField(), S = this._owner[this._propertyName + "SelectorNameArray"](), T = this._owner[this._propertyName + "NotificationSelectorNameDictionary"](), L = this._ownerDelegateSelectorPrefixSelectorMethod ? this._ownerDelegateSelectorPrefixSelectorMethod.call(this._owner) : null, O, P = 0, M, R = this._delegateCustomSelectors = {
    }, N = window.Gianduia.Foundation.NSNotificationCenter;
    if (T) {
        T.forEach(function (U) {
            N.removeObserver(this._delegate, T.objectForKey(U), U, this, true)
        }, this)
    } this._delegate = Q;
    K.reset();
    if (!S) {
        return
    } while ((M = S[P++])) {
        if (L && Q && (typeofQ[O = (L + M.capitalizedString())] === "function")) {
            R[M] = O;
            K.setValueForKey(true, M);
            this[M] = (new Function("return function() {return this._delegate." + O + ".apply(this._delegate,arguments);}"))()
        } else {
            if (Q && typeofQ[M] === "function") {
                R[M] = M;
                K.setValueForKey(true, M);
                this[M] = (new Function("return function() {return this._delegate." + M + ".apply(this._delegate,arguments);}"))()
            } else {
                K.setValueForKey(false, M);
                this[M] = function () {
                    return undefined
                }
            }
        }
    } if (T) {
        T.forEach(function (U) {
            N.addObserver(this._delegate, T.objectForKey(U), U, this, true)
        }, this)
    } return this
}
});
G.NSDelegateProperty = function (K) {
    return {
        isProperty: true, propertyDescription: K, createPropertyNamed: arguments.callee.createPropertyNamed
    }
};
G.NSDelegateProperty.createPropertyNamed = function (P, R) {
    var O = "_" + P, L = P + "Proxy", N = "_" + P + "BitFieldDefinition", Q = "_" + P + "SelectorNameArray", M = "_" + P + "NotificationSelectorNameDictionary", S = R.delegateNotificationSelectorNames, K = R.delegateSelectorNames;
    this[P + "BitFieldDefinition"] = function () {
        if (!this.constructor.prototype[N]) {
            var T = [];
            if (K) {
                T.addObjectsFromArray(((typeofK === "string") ? this[K]() : ((K.constructor === Array) ? K : null)))
            } if (S) {
                T.addObjectsFromArray(((typeofS === "string") ? this[S]() : ((S.constructor === Array) ? this._delegateSelectorNames : null)))
            } this.constructor.prototype[N] = new C(T)
        } return this[N]
    };
    this[P + "SelectorNameArray"] = function () {
        if (this[Q] === undefined) {
            this[Q] = (K) ? ((typeofK === "string") ? this[K]() : ((K.constructor === Array) ? K : null)) : null
        } return this[Q]
    };
    this[P + "NotificationSelectorNameDictionary"] = function () {
        if (this[M] === undefined) {
            this[M] = (S) ? ((typeofS === "string") ? this[S]() : ((S.isKindOfClass(Gianduia.Foundation.NSDictionary)) ? S : null)) : null
        } return this[M]
    };
    this[L] = function () {
        if (!this[O]) {
            this[O] = H.delegateProxyForOwnerPropertyNamePropertyDescription(this, P, R)
        } return this[O]
    };
    R.setterImplementation = function (T) {
        this[L]().setDelegate(T)
    };
    R.getterImplementation = function (T) {
        return this[L]().delegate()
    };
    this.addNSPropertyNamed(R, P)
};
D.addNSDelegatePropertyNamed = function (L, K) {
    NSDelegateProperty.call(window, L).createPropertyNamed.call(this, K, L)
};
Object.nsIdCounter = -1;
Object.readOnlyNSId = function () {
    return this._nsId
};
G._nsId = D._nsId = null;
G.nsId = D.nsId = F.nsId = function () {
    if (!this._nsId) {
        this._nsId = "ID"++ + Object.nsIdCounter;
        this.nsId = this.nsHashValue = Object.readOnlyNSId;
        return this._nsId
    } return this._nsId
};
G.nsHashValue = document.nsHashValue = D.nsHashValue = F.nsHashValue = D.nsId;
Number.prototype.nsHashValue = function () {
    return this
};
Number.prototype.isEqual = function (K) {
    return (this.valueOf() === K.valueOf())
};
Number.prototype.constrain = function (L, K) {
    return (this < L) ? L : ((this > K) ? K : this)
};
D.description = D.toString;
Boolean.prototype.description = Number.prototype.description = function () {
    return this
};
D.isEqual = function (K) {
    return (this === K)
};
D._classNameReadOnly = function () {
    return this.__className
};
D.className = function () {
    return this.__className
};
G.className = G.toString;
D.superclass = function () {
    return this.constructor.superclass()
};
D.qualifiedClassName = function () {
    return this.constructor.qualifiedClassName()
};
D._faultHandler = null;
D.faultHandler = function () {
    return this._faultHandler
};
D.isFault = function () {
    return (this._faultHandler !== null)
};
D.methodNamed = function (K) {
    return (typeofthis[K] === "function") ? this[K] : null
};
D._setterByKey = null;
D.setterForKey = function (K) {
    return this.methodNamed(this.setterSelectorForKey(K))
};
D._setterSelectorForKey = {
};
D._setterSelectorForKeyReplaceFunction = function (K, L) {
    return "set" + L.toUpperCase()
};
D.setterSelectorForKey = function (K) {
    return (this._setterSelectorForKey.hasOwnProperty(K)) ? this._setterSelectorForKey[K] : (this._setterSelectorForKey[K] = ("set" + K.charAt(0).toUpperCase() + K.substring(1, K.length)))
};
D.forEach = function (M, K) {
    if (!K) {
        K = window
    } for (var L in this) {
        if (this.hasOwnProperty(L)) {
            M.call(K, L)
        }
    }
};
D.objectForKey = function (K) {
    return this[K]
};
D.setObjectForKey = function (K, L) {
    this[L] = K
};
F.parentClassName = null;
F.specialize = function (L) {
    var K;
    if (this === L) {
        throw "specialize: Error - cannot inherit from self"
    } else {
        if (!L) {
            throw "specialize: Cannot inherit from " + L
        }
    } if (typeofL === "function") {
        K = this.prototype = new L();
        K.__className = this._name;
        K.constructor = this;
        K.parent = L.prototype;
        this.parent = L
    } else {
        K = this.prototype = L;
        K.constructor = this;
        K.parent = L
    } return this
};
C = function () {
    this._flags = [];
    this._defaultValues = [];
    if (arguments.length) {
        this.addFlags.apply(this, arguments)
    } return this
};
C.setQualifiedClassName("Gianduia.Foundation.NSBitFieldDefinition");
C.Implements({
    generateProperties: NSProperty({
        defaultValue: false
    }), owner: NSProperty({
        defaultValue: null
    }), flags: function () {
        return this._flags
    }, _allTrueValue: 0, addFlags: function () {
        var M = 0, L, K = arguments[0], N = (K && K.constructor === Array) ? K : arguments;
        while ((L = N[M++])) {
            this.addFlag(L)
        }
    }, hasFlag: function (K) {
        return this.hasOwnProperty(K)
    }, addFlag: function (L, K) {
        if (!this.hasOwnProperty(L)) {
            var M = this._flags.length;
            this._flags[M] = L;
            this._allTrueValue += (this[L] = (1 << M));
            if (K) {
                this._defaultValues[this._defaultValues.length] = L;
                this._defaultValues[L] = K
            }
        }
    }, setDefaultValueForFlag: function (L, K) {
        this._defaultValues[iKey] = defaultValue
    }, defaultValueForFlag: function (L, K) {
        return this._defaultValues[iKey]
    }, flagsWithDefaultValue: function () {
        return this._defaultValues
    }, removeFlags: function () {
        var M = 0, L, N, K = arguments[0], P = (K && K.constructor === Array) ? K : arguments, O = this._flags;
        while ((L = P[M++])) {
            if (this.hasOwnProperty(L)) {
                N = O.length;
                O.removeObject(L);
                this._allTrueValue -= (this[L] = (1 << N))
            }
        }
    }, addNSPropertyFlagsFor: function (Q, K, P) {
        var O = 0, L, N, M = this;
        this._generateProperties = true;
        this._owner = K;
        while ((L = Q[O++])) {
            N = L.property;
            this.addFlag(N, L.defaultValue);
            if (K) {
                (L.setterImplementation = function (R) {
                    this.setValueForKeyPath(R, (P + "." + arguments.callee.key))
                }).key = N;
                (L.getterImplementation = function () {
                    return this.valueForKeyPath((P + "." + arguments.callee.key))
                }).key = N;
                K.addNSPropertyNamed(L, N)
            }
        } if (this._flags.length > 32) {
            Gianduia.Foundation.NSException.raiseExceptionWithNameReasonUserInfo(NSInternalInconsistencyException, "NSBitField contains more than 32 flags")
        }
    }
});
C.prototype.removeFlag = C.prototype.removeFlags;
A = function (N) {
    this.bitField = 0;
    this._bitFieldDefinition = N;
    var M = 0, L = N.flagsWithDefaultValue(), K;
    while (K = L[M++]) {
        this.setValueForKey(L[K], K)
    } return this
};
A.setQualifiedClassName("Gianduia.Foundation.NSBitField");
I = A.prototype;
A.Implements({
    reset: function () {
        this.bitField = 0
    }, bitFieldDefinition: function () {
        return this._bitFieldDefinition
    }, valueForKey: function (K) {
        return (this.bitField & this._bitFieldDefinition[K])
    }, setValueForKey: function (M, K) {
        var L = this.bitField;
        (M) ? (this.bitField |= this._bitFieldDefinition[K]) : (this.bitField &= ~(this._bitFieldDefinition[K]));
        if (this._delegate && (this.bitField === this._bitFieldDefinition._allTrueValue) && L !== this.bitField) {
            if (typeofthis._delegate[this._delegateSelector] === "function") {
                this._delegate[this._delegateSelector](this)
            }
        }
    }, isTrue: function () {
        return (this.bitField === this._bitFieldDefinition._allTrueValue)
    }, setDelegate: function (L, K) {
        this._delegateSelector = K ? K : "bitFieldIsTrue";
        this._delegate = L
    }, delegate: function (K) {
        return this._delegate
    }
});
G.NSBitfieldProperty = function (K) {
    return {
        isProperty: true, propertyDescription: K, createPropertyNamed: arguments.callee.createPropertyNamed
    }
};
G.NSBitfieldProperty.createPropertyNamed = function (M, Q) {
    var O = new C(), L = Q.flagProperties, N = 0, K, P;
    while (K = L[N++]) {
        P = K.property;
        O.addFlag(P, K.defaultValue);
        if (Q.createFlagProperties) {
            if (!K.setterImplementation) {
                (K.setterImplementation = function (R) {
                    this[M]().setValueForKey(R, arguments.callee.key)
                }).key = P
            } if (!K.getterImplementation) {
                (K.setterImplementation = function (R) {
                    return this[M]().valueForKey(arguments.callee.key)
                }).key = P
            } this.addNSPropertyNamed(K, P)
        }
    } if (!Q.getterImplementation) {
        (Q.getterImplementation = (new Function("return (function() {			if(!this._" + M + ") {				this._" + M + " = new NSBitField(arguments.callee.bitFieldDefinition);			}			return this._" + M + ";			 });"))()).bitFieldDefinition = O
    } this.addNSPropertyNamed(Q, M)
};
G.NSEnum = function (K, M) {
    for (var L = M.length - 1; L >= 0; L--) {
        if (M[L]) {
            window[M[L]] = L
        }
    }
}
})();
